<template>
  <el-container>
    <el-header>
      <div>
        <img src="http://www.hp.gov.cn/gkmlpt/gkml/pc/images/guohui.f9a92656.png">
        <span style="color:white">坪山区龙田街道</span>
      </div>
      <div>
        <el-tag type="success" style="margin-right:20px">用户名：{{username}}</el-tag>
        <el-tag type="primary" style="margin-right:20px" v-if="myidentity ==='1'">工作人员</el-tag>
        <el-tag type="primary" style="margin-right:20px" v-else>居民</el-tag>
        <el-button type="" @click="logout">退出</el-button>
      </div>

    </el-header>
    <el-container>
      <el-aside :width="isCollapse?'64px':'200px'">
        <div class="toggle-button" @click="toggleCollapse"> |||</div>
        <el-menu background-color="#313743" text-color="white" :unique-opened=true :collapse="isCollapse" :collapse-transition=false router :default-active="$route.path">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-headset"></i>
              <span>服务管理</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/addOrder">
              <i class="el-icon-menu"></i>
              <span>服务申请</span>
            </el-menu-item>
            <el-menu-item index="/myOrder">
              <i class="el-icon-menu"></i>
              <span>我的服务</span>
            </el-menu-item>
          </el-submenu>
          <!-- 工作人员管理 -->
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-s-management"></i>
              <span>社区工作</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/works">
              <i class="el-icon-menu"></i>
              <span>工作人员列表</span>
            </el-menu-item>
            <el-menu-item index="/allwork" v-if="this.myidentity==='1'">
              <i class="el-icon-menu"></i>
              <span>全部服务</span>
            </el-menu-item>
            <el-menu-item index="/mywork" v-if="this.myidentity==='1'">
              <i class="el-icon-menu"></i>
              <span>我的工作</span>
            </el-menu-item>
          </el-submenu>
          <!-- 居民管理 -->
          <el-submenu index="3" >
            <template slot="title">
              <i class="el-icon-tickets"></i>
              <span>居民与建筑信息</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/residentList" v-if="this.myidentity==='1'">
              <i class="el-icon-menu"></i>
              <span>居民列表</span>
            </el-menu-item>
            <el-menu-item index="/house">
              <i class="el-icon-menu"></i>
              <span>房屋信息列表</span>
            </el-menu-item>
          </el-submenu>
          <!-- 民情日志 -->
          <el-submenu index="7">
            <template slot="title">
              <i class="el-icon-notebook-2"></i>
              <span>民情日志</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/allLogs">
              <i class="el-icon-menu"></i>
              <span>全部日志</span>
            </el-menu-item>
            <el-menu-item index="/myLogs" v-if="this.myidentity==='1'">
              <i class="el-icon-menu"></i>
              <span>我的日志</span>
            </el-menu-item>
          </el-submenu>
          <!-- 疫情管理 -->
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-help"></i>
              <span>疫情管理</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/goods">
              <i class="el-icon-menu"></i>
              <span>疫情物资分配</span>
            </el-menu-item>
            <el-menu-item index="/disinfect">
              <i class="el-icon-menu"></i>
              <span>社区消毒打卡</span>
            </el-menu-item>
          </el-submenu>
          <!-- 个人信息 -->
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-user-solid"></i>
              <span>个人信息</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/mine">
              <i class="el-icon-menu"></i>
              <span>详细信息</span>
            </el-menu-item>
            <el-menu-item index="/changpassword">
              <i class="el-icon-menu"></i>
              <span>修改密码</span>
            </el-menu-item>
          </el-submenu>
          <!-- 社区信息 -->
          <el-submenu index="6">
            <template slot="title">
              <i class="el-icon-warning"></i>
              <span>社区信息</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/Stree">
              <i class="el-icon-menu"></i>
              <span>龙田社区信息</span>
            </el-menu-item>
            <el-menu-item index="/myCharts">
              <i class="el-icon-menu"></i>
              <span>居民信息可视化</span>
            </el-menu-item>
          </el-submenu>

        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  data () {
    return {
      username: window.sessionStorage.getItem('userName'),
      myidentity: window.sessionStorage.getItem('identity'),
      isCollapse: false
    }
  },
  created () {},
  methods: {
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
    },
    logout () {
      sessionStorage.removeItem('token')
      this.$router.push('/login')
    }
  },
  computed: {
    ...mapGetters(['identity'])
  }
}
</script>

<style lang="less" scoped>
.el-header {
  background-color: #363d40;
  display: flex;
  justify-content: space-between;
  padding-left: 10px;
  align-items: center;
  font-size: 20px;

  > div {
    padding-left: 10px;
    display: flex;
    align-items: center;
  }
  img {
    width: 50px;
    height: 50px;
    margin-right: 15px;
  }
}
.el-aside {
  background-color: #313743;

  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #acdaf8;
}

section {
  width: 100%;
  height: 100%;
}

.toggle-button {
  background-color: rgba(6, 95, 228, 0.63);
  font-size: 10px;
  line-height: 24px;
  color: wheat;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
